//
//  YZMAnnouncementCell.m
//  YZMicroStock
//
//  Created by Lv.Dongdong on 2017/3/8.
//  Copyright © 2017年 cqjr. All rights reserved.
//

#import "YZMAnnouncementCell.h"
#import <DateTools.h>

@interface YZMAnnouncementCell()

@property (nonatomic, strong) UILabel *titleLB;
@property (nonatomic, strong) UILabel *timeLB;
@property (nonatomic, strong) UIView *topLine;

@end

@implementation YZMAnnouncementCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createObjects];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)createObjects {
    
    WS(ws);
    self.titleLB = [YZMAppStyle labelWithMediumWhite];
    self.titleLB.adjustsFontSizeToFitWidth = YES;
    self.titleLB.minimumScaleFactor = 0.5;
    [self.contentView addSubview:self.titleLB];
    [self.titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(ws.contentView).offset(7);
        make.left.equalTo(ws.contentView).offset(20);
        make.right.equalTo(ws.contentView).offset(-20);
    }];
    
    self.timeLB = [YZMAppStyle labelWithSmallLightGray];
    [self.contentView addSubview:self.timeLB];
    [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(ws.contentView).offset(-7);
        make.left.equalTo(ws.titleLB);
    }];
    
    self.arrowImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"white_arrow_down"]];
    [self.contentView addSubview:self.arrowImage];
    [self.arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(ws.contentView);
        make.right.equalTo(ws.contentView).offset(-20);
    }];
    
    self.topLine = [YZMAppStyle splitLine];
    [self.contentView addSubview:self.topLine];
    [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.equalTo(ws.contentView);
    }];
    
    self.bottomLine = [YZMAppStyle splitLine];
    [self.contentView addSubview:self.bottomLine];
    [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.left.right.equalTo(ws.contentView);
    }];
}

- (void)setModel:(YZMAnnouncementListModel *)model {
    
    self.titleLB.text = model.noticeTitle;
    self.timeLB.text = [model.releaseTime formattedDateWithFormat:@"yyyy-MM-dd HH:mm"];
}

@end
